﻿// ===============================================================================
// DotNet.Platform 开发框架 2016 版权所有
// ===============================================================================

using System;
using System.Web.Mvc;
using DotNet.Extensions;
using DotNet.Web.Controllers;
using DotNet.JCore.Entity;
using DotNet.Auth.Utility;

namespace DotNet.Web.Controllers
{
    public class PointStationLineSumController : BaseController
    {
        private PointStationLineSumService Service = new PointStationLineSumService();
        public ActionResult Index()
        {
            var currentUser = AuthHelper.GetSessionUser();
            if (!currentUser.IsAdmin)
            {
                ViewBag.pointId = CurrentEmployee.PointId;
            }
            return View();
        }
        public ActionResult Grid(string startDate, string endDate, string PointID, string name, string StationId, string LineFlag)
        {
            //先统计一下当日数据，将当日数据插入表中，再执行查询
            if (LineFlag == null)
            {
                LineFlag = "1";
            }
            Service.Proc_InspectorRegistrationSum("Proc_PointStationLineSum", LineFlag);
            var list = Service.GetPageList(PageInfo(), startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull(), PointID, name, StationId, LineFlag);
            ViewBag.LineFlag = LineFlag;
            return View(list);
        }
        public ActionResult Export(string startDate, string endDate, string PointID, string name, string StationId, string LineFlag)
        {
            return Export(Service.GetList(startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull(), PointID, name, StationId, LineFlag));
        }
        private ActionResult NotFound(string id)
        {
            return NotFound("获取 信息 错误", $"无法找到 主键 = {id} 的信息");
        }
    }
}
